package com.yyf.spring.boot.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yyf.spring.boot.dto.User;
import com.yyf.spring.boot.mapper.UserMapper;
import com.yyf.spring.boot.service.UserService;
import com.yyf.spring.boot.vo.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper mapper;

	@Override
	public Message listUser(int pn) {
		PageHelper.startPage(pn, 5);
		List<User> userList = mapper.selectAll();
		//2.将查询后的结果封装到一个pageInfo里面,可以传入连续显示的页数
		PageInfo pageInfo = new PageInfo(userList, 5);
		return Message.success().add("pageInfo", pageInfo);
	}
}
